package myfirstgrailsproject

/**
 * This class provides filters which prevent users from 
 * doing certain actions based on their userType.
 * 
 * @author zach
 *
 */
class AdminFilters {

    def filters = {
		//Effectively everything except for logging in/out and authentication
        all(controller:'*', action:"(create|edit|update|delete|list|show)") {
            before = {
				//checks if the session is null, and the user exists
                if (!session?.user){
					flash.message = "You must be logged in first."
					redirect(controller:"user", action:"login")
					return false;
				}
            }
            after = {
                
            }
            afterView = {
                
            }
        }
		
    }
    
}
